package com.blog.service.impl;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.blog.service.entity.Resource;
import com.blog.service.inter.ResourceService;
import com.blog.service.model.ResourceMapper;

/**
 * 文件名： com.blog.service.impl.ResourceServiceImpl.java
 * 作者： WenBin
 * 日期： 2017年4月12日
 * 功能说明： 资源服务类
 * =========================================================
 * 修改记录：
 * 修改作者 日期 修改内容
 * =========================================================
 * Copyright (c) 2010-2011 .All rights reserved.
 */
@Service
public class ResourceServiceImpl implements ResourceService {

	@Autowired
	private ResourceMapper resourceMapper;

	@Override
	public Resource saveResource(Resource resource) {

		int i = resourceMapper.insertSelective(resource);
		if (i > 0) {
			return resource;
		}
		return null;
	}

	@Override
	public Resource updateResource(Resource resource) {

		int i = resourceMapper.updateByPrimaryKey(resource);
		if (i > 0) {
			return resource;
		}
		return null;
	}

	@Override
	public Resource deleteResource(Resource resource) {

		int i = resourceMapper.deleteByPrimaryKey(resource.getResourceId());
		if (i > 0) {
			return resource;
		}
		return null;
	}

}
